var inervalId; //接收进度条时间
var initialopen=1; //初始化  表示第一次打开页面  第一次打开页面时 window窗口还没加载完毕，onSelect()事件直接调用 窗口会报错
var menuId='门卫管理访单';
const currentVisit = {};
let displayProgressDlg = false;

function isEnter(str){
    return str === '\n';
}

function isFullData(data){
    const arr = data.split(',');
    const len = arr.length === 3;
    let lastc = arr[2];
    lastc = lastc === undefined ? '' : lastc;
    lastc = lastc === null ? '' : lastc;
    const b = lastc.length > 0 ;

    return len && b;
}

$(function () {
    $('#FHwin').window({
        width: 400,
        height: 445,
        modal:true,collapsible:false,minimizable:false,maximizable:false,
        draggable:false,
        resizable:false,
        closed:true,
        noheader: true,
        closable:false
    });

    //全局 添加自定义请求头
    $.ajaxSetup({
        headers: {"usersid":Strusersid}
    });

    initKendoUiGrid()

    let intervalId = setInterval(function() {
        seteslfocus(); //指定焦点位置
    }, 2000); // 每隔2000毫秒执行这个函数

    // clearInterval(intervalId);

    let intervalGrid = setInterval(function() {
        btn_refresh(); //
    }, 5000); // 每隔2000毫秒执行这个函数

    btn_refresh();


    //绑定扫码事件
    var input = document.getElementById('esl');
    // input.addEventListener('input', function(event) {
    //     var value = event.target.value;
    //     console.log('扫描得到的数据：', value);
    //     if (value.length>0 && isFullData(value)){
    //         ScanCode(value);
    //         input.value = '';
    //     }
    // });

    input.addEventListener("keyup", function(event) {
        event.preventDefault();
        if (event.keyCode === 13) {
            var value = event.target.value;
            if (value.length>0 && isFullData(value)){
                ScanCode(value);
                input.value = '';
            }else{// 清理掉之前的非法数据
                input.value = '';
            }
        }else if(event.keyCode === 36){// 两个按钮的对话框右边的按钮 - 确定
            if(displayProgressDlg) setEntryOrLeave();
            closeMsgDlg();
        }else if(event.keyCode === 35){// 两个按钮的对话框右边的按钮 - 取消
            closeProgressDlg();
            closeMsgDlg();
        }
    });

    let countdownTime = 5; // 倒计时起始时间
    let countdownInterval; // 存储setInterval的ID
    // 更新倒计时的函数
    function updateCountdown() {
        countdownTime--; // 减少倒计时时间
        // document.getElementById("countdown").innerText = `剩余${countdownTime}秒自动刷新`;
        document.getElementById("countdown").innerHTML = `剩余${countdownTime}秒自动刷新`;

        // 如果倒计时结束，重置为5秒并重新开始
        if (countdownTime <= 0) {
            countdownTime = 5;
        }
    }
    // 每秒调用一次updateCountdown函数
    countdownInterval = setInterval(updateCountdown, 1000);

});

//扫码获取数据
function ScanCode(value) {
    const that = this;
    $.messager.progress();
    $.ajax({
        url:'https://showawx.xdfznh.club/visitorbe/visit/scanEntryQrcode',
        type: 'POST',
        dataType: 'json',
        data:value,
        contentType: "application/json;charset=UTF-8",
        success: function (res) {
            const { success,msg,data } = res;
            if(!success){
                showDlgMsg(msg);
                return
            }

            $("#form").form('load', data);
            that.currentVisit = {...data};
            // 根据不同状态显示不同的提示
            showDialog(data);
        },
        complete: function (XMLHttpRequest, textStatus) {
            $.messager.progress('close');
        }
    });
}

//设置接收扫码数据的文本 焦点
function seteslfocus() {
    document.getElementById('esl').focus();
    //document.getElementById("esl").value="";
}

//查询
function btn_refresh() {
    btn_refresh_zc();
    // switch (getSelectedIndex()) {
    //     case 0:
    //         btn_refresh_zc();
    //         break;
    //     case 1:
    //         // btn_refresh_zf();
    //         break;
    // }
}


function GetBillcode() {
    $.ajax({
        // headers: {"usersid":Strusersid},
        // url: strLin + "customSqlAccount/callProc",
        url:'https://showawx.xdfznh.club/visitorbe/visit/getVisit4Doorman',
        type: 'POST',
        dataType: 'json',
        // data: JSON.stringify(['usp_getquality_sum04',YMD,linezl]),
        contentType: "application/json;charset=UTF-8",
        success: function (cdata) {
            let data=cdata.data;
            kGrid.dataSource.data(data);
        },
        complete: function (XMLHttpRequest, textStatus) {

        }
    });
}

function btn_refresh_zc() {
    var kGrid = $("#bill").data("kendoGrid");
    $.ajax({
        // headers: {"usersid":Strusersid},
        // url: strLin + "customSqlAccount/callProc",
        url:'https://showawx.xdfznh.club/visitorbe/visit/getVisit4Doorman',
        type: 'POST',
        dataType: 'json',
        // data: JSON.stringify(['usp_getquality_sum04',YMD,linezl]),
        contentType: "application/json;charset=UTF-8",
        success: function (cdata) {
            let data=cdata.data;
            kGrid.dataSource.data(data);
        },
        complete: function (XMLHttpRequest, textStatus) {

        }
    });
}

/**
 * 将数组去重
 * @param arr
 * @param attribute
 * @returns {[]}
 */
function unique(arr, attribute) {
    let new_arr = [];
    let json_arr = [];
    for (let i = 0; i < arr.length; i++) {
        if (new_arr.indexOf(arr[i][attribute]) == -1) {
            new_arr.push(arr[i][attribute]);
            json_arr.push(arr[i]);
        }
    }
    return json_arr;
}


// 全部 构建表结构
function initKendoUiGrid() {
    var SUFFIX='_01';
    /*不做过滤，这块代码删除掉了*/
    var progress = new kendo.data.DataSource({data: []});
    var dataSource = new kendo.data.DataSource({
        pageSize: 200,
        schema: {
            model: {
                fields: {
                    // duration_hour: {type: "number"},
                }
            }
        },
        aggregate: [
            // {field: "duration_hour", aggregate: "sum"},
        ],
        change: function (e) {
            //获取过滤条件
            let filtrer = this.filter();
            //获取所有数据
            let allData = this.data();
            //进行过滤条件的筛选
            let query = new kendo.data.Query(allData);
            //获取过过滤后的数据
            // let data = query.filter(filtrer).data;
            let data = allData;
            // progress.data(unique(data, 'progress'));


        },
        requestStart: function (e) {
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('disable')
                }
            })
        },
        requestEnd: function (e) {
            let response = e.response;
            if (response && response['message']) {
                $.messager.show({title: '提示', msg: response['message']})
            }
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('enable')
                }
            })
        }
    });

    let columns=[
        {
            field: "", title: "序号",template: "<span class='row_number'></span>", width: 40
        },
        {field: 'id', title: '主表主键', hidden: true, width: 80,},

        {
            title: "来访信息",
            headerAttributes: {style: 'text-align:center;margin-right: 2px;'},
            columns: [
                {
                    hidden: true,
                    field: 'visitorNickName',
                    title: '微信昵称',
                    width: 80,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: visitor_nick_name},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'visitorRealName',
                    title: '真实姓名',
                    width: 80,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: visitor_real_name},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'visitorCompany',
                    title: '公司名称',
                    width: 100,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: visitor_company},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'category',
                    title: '来访类型',
                    width: 80,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: category},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'remark',
                    title: '来访缘由',
                    width: 100,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: remark},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'numberOfPeople',
                    title: '随行人数',
                    width: 50,
                    filterable: false ,
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'visitorPhone',
                    title: '手机号',
                    width: 100,
                    filterable: false ,
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'carNumber',
                    title: '车牌号',
                    width: 80,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: car_number},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'startTime',
                    title: '起始时间',
                    width: 100,
                    filterable: false ,
                    // attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'endTime',
                    title: '终止时间',
                    width: 100,
                    filterable: false ,
                    // attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
            ]
        },
        {
            title: "受访信息",
            headerAttributes: {style: 'text-align:center;margin-right: 2px;'},
            columns: [
                {
                    field: 'intervieweeRealName',
                    title: '受访人员',
                    width: 100,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: interviewee_real_name},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },
                {
                    field: 'intervieweeDepartment',
                    title: '部门',
                    width: 100,
                    filterable: false ,
                    // filterable: {multi: true, search: true, dataSource: interviewee_department},
                    attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
                    headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
                },

            ]
        },

        {
            field: 'progress',
            title: '进度',
            width: 100,
            filterable: false ,
            // filterable: {multi: true, search: true, dataSource: progress},
            attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
            headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
        },
        {
            field: '',
            title: '',
            width: 100,
            attributes: {style: 'text-align:center;white-space:nowrap;text-overflow:ellipsis;'},
            headerAttributes: {style: 'text-align:center;margin-right: 2px;'}
        },

    ];
    var grid = $("#bill").kendoGrid({
        sortable: true,
        resizable: true,
        selectable: "multiple row",
        editable: false,
        filterable: true,
        persistSelection: true,
        allowCopy: true,
        title: "报表",
        // columnMenu: {
        //     sortable: true
        // },
        excel: {
            fileName: "门卫访单.xlsx",
            proxyURL: "",
            allPages: true,
            filterable: true
        },
        pageable: {
            pageSize: 200
        },
        dataSource: dataSource,
        columns: columns,
        reorderable: true,
        height: '99%',
        dataBound: function () {  //dataBound 事件在网格数据绑定完成后触发。您可以使用该事件来执行与数据绑定后相关的操作，例如修改数据、设置样式、执行计算等
            var rows = this.items();
            $(rows).each(function () {
                var index = $(this).index() + 1;
                var rowLabel = $(this).find(".row_number");
                $(rowLabel).html(index);
            });
            var kgrid = $("#bill").data("kendoGrid");    // 行样式
            let trs = kgrid.tbody.find("tr");
            trs.each(function (i, row) {
                let data = kgrid.dataItem(row);
                // let daydiff = data['daydiff'];
                let audit_department = data['audit_department_state'];
                let audit_factory = data['audit_factory_state'];
                let audit_personnel = data['audit_personnel_state'];
                let audit_manager = data['audit_manager_state'];

                // if (state == 0) $(row).css({"color": "red", "text-decoration": "line-through"});
                // if (daydiff < 0) $(row).css({"color": "red"});
                if (audit_department === 2 || audit_factory === 2 || audit_personnel === 2 || audit_manager === 2 ) $(row).css({"color": "#0000FF"});
            });
        },

        columnResize: function (e) {  // 使用 columnResize 事件来监听列调整大小的操作。这个事件会在用户调整列宽时触发
            let field = e.column.field;
            let newWidth = e.newWidth;
            let oldWidth = e.oldWidth;

            if (newWidth < 20) {
                // $(this).hideColumn(field);
                var grid = $("#bill").data("kendoGrid");
                grid.hideColumn(field);
            } else {
                var Strcolumns={
                    'objectSid':menuId + SUFFIX,
                    "styleList": [{'fieldName':field,'columnWidth':newWidth}]
                };
                $.ajax({
                    url: strLin + 'customTableStyle/updateStyleMult',
                    traditional: true,
                    type: 'POST',
                    dataType: 'json',
                    data: JSON.stringify(Strcolumns),
                    contentType: "application/json;charset=UTF-8",
                    success: function (cdata) {
                        var data=cdata.data;
                    }
                });
            }
        },
        columnHide: function (e) {  //列隐藏事件
            let field = e.column.field;
            var Strcolumns={
                'objectSid':menuId + SUFFIX,
                "styleList": [{'fieldName':field,'hidden':1}]
            };
            $.ajax({
                url: strLin + 'customTableStyle/updateStyleMult',
                traditional: true,
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(Strcolumns),
                contentType: "application/json;charset=UTF-8",
                success: function (cdata) {
                    var data=cdata.data;
                }
            });
        },
        columnShow: function (e) {  //列显示事件
            let field = e.column.field;
            var Strcolumns={
                'objectSid':menuId + SUFFIX,
                "styleList": [{'fieldName':field,'hidden':0}]
            };
            $.ajax({
                url: strLin + 'customTableStyle/updateStyleMult',
                traditional: true,
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(Strcolumns),
                contentType: "application/json;charset=UTF-8",
                success: function (cdata) {
                    var data=cdata.data;
                }
            });
        },
        columnReorder: function (e) {  //  columnReorder 事件来监听列重新排序的操作
            var newColumns = JSON.parse(JSON.stringify(e.sender.columns));
            newColumns = reorder(newColumns, e.oldIndex, e.newIndex);

            var col = [];
            for (let i = 0; i < newColumns.length; i++) {
                if (newColumns[i]['field'])
                    col.push({
                        seq: i,
                        fieldName: newColumns[i]['field'],
                        columnWidth:newColumns[i]['width'],
                        hidden:newColumns[i]['hidden']
                    });
            }

            var Strcolumns={
                'objectSid':menuId + SUFFIX,
                "styleList": col
            };
            $.ajax({
                url: strLin + 'customTableStyle/updateStyleMult',
                traditional: true,
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(Strcolumns),
                contentType: "application/json;charset=UTF-8",
                success: function (cdata) {
                    var data=cdata.data;
                }
            });
        },
    });

    var grid01 = $('#bill').data('kendoGrid');
    let columnNames = [];
    columns.forEach(item => {
        if (item['field']) {
            columnNames.push(item['field']);
        }
    });
    loadOptions(grid01, columnNames, columns, SUFFIX);

    //双击事件
    grid.on('dblclick', 'tr', function () {
        //  代码
        var kGrid = $("#bill").data("kendoGrid");
        var row = kGrid.select();
        var dataItem = kGrid.dataItem(row);
        var id = dataItem['id'];
        opwinA(id)

    });
    //右击事件
    grid.on('contextmenu', 'tr', function (e) {
        // e.preventDefault();
        // //  代码
        // var menu = '<div id="menu">'
        //     + '<div data-options="iconCls:\'icon-ok\'">审核通过</div>'
        //     + '<div data-options="iconCls:\'icon-undo\'">审核驳回</div>'
        //     + '<div data-options="iconCls:\'icon-clear\'">审核取消</div>'
        //     + '<div data-options="iconCls:\'icon-no\'">审核作废</div>'
        //     + '</div>';
        // if ($('#menu').length <= 0) {
        //     $('body').append(menu);
        // }
        // $('#menu').menu({
        //     onClick: function (item) {
        //         switch (item.text) {
        //             case '审核驳回':
        //                 // setaudit(2);
        //                 $('#B').window('open');
        //                 //光标定位
        //                 $('#B_remark').textbox().next('span').find('input').focus();
        //                 break;
        //             case '审核作废':
        //                 setstate_zf(0);
        //                 break;
        //             case '审核通过':
        //                 setaudit(1);
        //                 break;
        //             case '审核取消':
        //                 setaudit(0);
        //                 break;
        //
        //         }
        //     }
        // });
        // $('#menu').menu('show', {
        //     left: e.pageX,
        //     top: e.pageY
        // });
    });
    //  单击事件
    grid.on('click', 'tr', function () {
        //  代码
        // setStatusA('0-1')
        // $('#bt_ll').linkbutton('enable');
        // $('#bt_ll01').linkbutton('enable');

    });
}

//列隐藏显示模态窗
function btn_open_column_list() {
    let kGrid =$('#bill01').data('kendoGrid'); // getSelectedGrid();
    let options = kGrid.getOptions().columns;
    if ($('#btn_open_column_list').length <= 0) {
        let div = $(`<div data-options="
                    resizable:true,iconCls:'icon-filter',width:200,height:400,modal:true,title:'列',
                    onClose:function(){$(this).dialog('destroy')}" 
                          class="easyui-dialog" id="btn_open_column_list">
                   </div>`);
        let form = $('<form style="width: 100%;height: 100%;"></form>')
        for (let i of options) {
            if (i.field) {
                let checkbox = $(`<div style="width: 100%;height: auto;padding: 5px;">
                <input class="easyui-checkbox" name="${i.field}" data-options="label:'${i.title}',
                labelWidth:120,value:true,name:'${i.field}'">
                </div>`);
                form.append(checkbox);
            }
        }
        let container = $(`<div></div>`);
        form.appendTo(div);
        div.appendTo(container);
        $('body').append(container);
        $.parser.parse($('#btn_open_column_list').parent());
        let formData = {};
        options.map(item => {
            formData[item['field']] = item['hidden'] == undefined ? true : !item['hidden'];
        })
        $('#btn_open_column_list form').eq(0).form('load', formData);
        $('#btn_open_column_list form .easyui-checkbox').each(function () {
            //  绑定事件
            $(this).checkbox({
                onChange: function (checked) {
                    let opts = $(this).checkbox('options');
                    if (checked) {
                        kGrid.showColumn(opts.name);
                    } else {
                        kGrid.hideColumn(opts.name);
                    }
                }
            })
        })
    } else {
        $('#btn_open_column_list').dialog('open');
    }
}

//  清除过滤
function btn_cancel_filter() {
    let kGrid0 = $("#bill01").data("kendoGrid");
    // let kGrid0 =getSelectedGrid()
    if (kGrid0 != undefined) {
        kGrid0.dataSource.filter({});
    }
}


//导出
function btn_export() {
    if (!determineQX(menuId,'pexport')){
        //$.messager.alert('提示', '当前登录账号无权限！');
        showDlgMsg('您没有权限进行本操作！');
        return;
    }
    $("#bill01").data("kendoGrid").saveAsExcel();

    // switch (getSelectedIndex()) {
    //     case 0:
    //         $("#bill").data("kendoGrid").saveAsExcel();
    //         break;
    //     case 1:
    //         $("#bill_zf").data("kendoGrid").saveAsExcel();
    //         break;
    // }
}

function getSelectedIndex() {
    let tab = $('#tabs').tabs('getSelected');
    let index = $('#tabs').tabs('getTabIndex', tab);
    return index;
}

/****************************************************************************************** */

//关闭当前标签页事件
function closeTab() {
    window.parent.closeTab();
}

/**
 * 根据扫码的访单的状态设置显示：进场、离场
 * @param visit 扫码后端响应来的访单数据
 */
function updateModalShow(visit){
    if(!visit) return;
    const progress = progressEnum[visit.progress].next ?? progressEnum.待进场.next;
    const btn = document.getElementById("btnSetProgress");
    btn.value = progress;
}

/**
 * 门卫扫码后根据访单状态提示门卫下一步操作
 * 1. 当前进度状态 = 待审核，显示消息提示门卫联系受访者审核访客的访单
 * 2. 待进场状态则显示“进场”，已进场则显示为“离场”
 * @param visit 扫码后端响应来的访单数据
 */
function showDialog(visit){
    // 被驳回则提示无法使用
    const { audit, rejectRemark } = visit;
    if(audit === -1){// 被驳回的访单提示后退出
        const msgContentEle = document.getElementById('dlg-msg-content');
        msgContentEle.textContent = `访单被驳回:【${rejectRemark}】\n 请访客重新制作访单！`;
        $('#dlg-msg-common').dialog('open');
        return
    }

    // 待审核则提示请求审核
    if(visit.progress === progressEnum.待审核.value){
        // 提醒电话受访者审核
        const phoneEle = document.getElementById('dlg-msg-phone');
        let phoneStr = visit.qrTicket ?? '';
        if(phoneStr.length === 0) phoneStr = '1*********8';
        phoneEle.textContent = phoneStr;// 存储过程中使用 employee.phone 替代了 visit.qr_ticket
        const nameEle = document.getElementById('dlg-msg-name');
        nameEle.textContent = visit.intervieweeRealName ?? '未知的姓名';
        $('#dlg-msg-audit').dialog('open');
        return
    }

    // 已经审核过的订单显示剩余的两个状态：进场、离场
    updateModalShow(visit);// 根据当前进度显示按钮的名称：进场、离场
    showDlgProgress();
}
function showDlgProgress(){// 显示有进度的对话框 - 两个按钮
    $('#FHwin').window('open');
    displayProgressDlg = true;
}
function closeProgressDlg(){
    $('#FHwin').window('close');
    displayProgressDlg = false;
}
/**
 * 2025年3月2日 16:16:12
 * 已经进场的访单则设置为 “离场” 状态，相反则设置为 “进场” 状态
 */
function setEntryOrLeave(){
    if(!this.currentVisit) return;
    const visit = {...this.currentVisit};
    const progress = visit.progress ?? progressEnum.待进场.value;
    if(!progress || progress.length === 0){
        console.log('访单没有进度，无法设置为下一个状态:', visit);
        return
    }
    const id = visit.id ?? 0;
    let url = '';
    if(progress === progressEnum.待进场.value){// 当前是待进场，设置为已进场
        url = `https://showawx.xdfznh.club/visitorbe/visit/setEntry/${id}`;
    }else if(progress === progressEnum.已进场.value){// 当前是已进场，设置为离场
        url = `https://showawx.xdfznh.club/visitorbe/visit/setLeave/${id}`;
    }else{
        //console.log('访单状态不对，无法设置为下一个进度：', visit);
        closeProgressDlg();
        return
    }

    // 执行请求
    $.messager.progress();
    $.ajax({
        type: 'POST', dataType: 'json', contentType: "application/json;charset=UTF-8", url: url,
        success: function (res) {
            const { success, msg, data } = res;
            if(!success){
                $.messager.show({title: '提示', msg: msg})
                return
            }
            // 请求成功关闭对话框并刷新表格数据
            closeProgressDlg();
            btn_refresh();
        },
        complete: function (XMLHttpRequest, textStatus) {
            $.messager.progress('close');
        }
    });
}

/**
 * 显示自定义的基于对话框的消息提示
 * @param msg 消息提示的内容 - 字符串
 */
function showDlgMsg(msg){
    const msgEle = document.getElementById('dlg-msg-prompt');
    msgEle.textContent = msg;
    $('#dlg-msg').dialog('open');
}

/**
 * 设置全屏
 */
function fullScreen() {
    var el = document.documentElement;
    var rfs = el.requestFullScreen || el.webkitRequestFullScreen ||
        el.mozRequestFullScreen || el.msRequestFullScreen;
    if (typeof rfs != "undefined" && rfs) {
        rfs.call(el);
    } else if (typeof window.ActiveXObject != "undefined") {
        // for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript != null) {
            wscript.SendKeys("{F11}");
        }
    }
}

/*
 * 退出全屏
 */
function exitFull() {
    // 判断各种浏览器，找到正确的方法
    var exitMethod = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.webkitExitFullscreen;
    if (exitMethod) {
        exitMethod.call(document);
    }
    else if (typeof window.ActiveXObject !== "undefined") {// for// Internet// Explorer
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript !== null) {
            wscript.SendKeys("{F11}");
        }
    }
}
// 关闭所有只有确定按钮的消息对话框
function closeMsgDlg(){
    $('#dlg-msg-audit').dialog('close');
    $('#dlg-msg').dialog('close');
}
